package pers.fjl.test.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import pers.fjl.common.constant.MessageConstant;
import pers.fjl.common.entity.QueryPageBean;
import pers.fjl.common.entity.Result;
import pers.fjl.common.po.Sales;
import pers.fjl.common.po.User;
import pers.fjl.common.validation.ValidGroup;
import pers.fjl.common.vo.AddSales;
import pers.fjl.test.annotation.LoginRequired;
import pers.fjl.test.service.SalesService;

import javax.annotation.Resource;

/**
 * 商品购买模块
 *
 * @author fangjiale 2020年1月2日
 */

@Api(value = "商品购买模块", description = "商品购买模块的接口信息")
@RequestMapping("/goods/sales")
@RestController
@CrossOrigin
public class SalesController {
    @Resource
    private SalesService salesService;

    @LoginRequired
    @ApiOperation(value = "分页查询", notes = "返回分页数据")
    @PostMapping("/findPage")
    public Result findPage(@RequestBody QueryPageBean queryPageBean) {
        return new Result(true, MessageConstant.OK, "获取分页数据成功", salesService.findPage(queryPageBean));
    }

    @ApiOperation(value = "添加订单", notes = "添加购买清单信息")
    @PostMapping("/add")
    public Result add(@RequestBody AddSales addsales) {
        boolean flag = salesService.addSales(addsales);
        return new Result(flag, MessageConstant.OK);
    }
}
